| API Documentation |  |

- MAIN PAGE
- NAMESPACES
- CLASSES

Public Member Functions | List of all members
nkGraphics::DefaultRenderStrategy Class Referencefinal

The default render strategy used within the component. More...

Inheritance diagram for nkGraphics::DefaultRenderStrategy:

## Public Member Functions
| DefaultRenderStrategy () noexcept
virtual | ~DefaultRenderStrategy ()
const nkMemory::BufferCast< SlotEntry > & | getSlots () const
float | getLodQualityFactor () const
bool | getFrustumCull () const
bool | getOrderQueue () const
bool | getUseLodSystem () const
void | setLodQualityFactor (float value)
void | setFrustumCull (bool value)
void | setOrderQueue (bool value)
void | setUseLodSystem (bool value)
virtual RenderCommandQueue | bakeRenderCommandQueue (Shader *shader, bool transparent) override
virtual void | updateAddRenderSlot (Entity *ent, const EntityRenderInfoSlot *slot) override
virtual void | updateEraseRenderSlot (Entity *ent, const EntityRenderInfoSlot *slot) override
Public Member Functions inherited from nkGraphics::RenderStrategy
| RenderStrategy ()
virtual | ~RenderStrategy ()

## Detailed Description

The default render strategy used within the component.

The strategy offers, out of the box, a way to render passes with some optimizations.
It will by default frustum cull, reorder, and collapse commands in an attempt to limit their number, and reduce the amount of GPU calls.

It will also use the rendering information by selecting one LOD to render from each slots provided. The selection will happen based on its quality metric, which is expected to represent its relative height in the view frustum.

## Constructor & Destructor Documentation

## ◆ DefaultRenderStrategy()

nkGraphics::DefaultRenderStrategy::DefaultRenderStrategy | ( |  | ) |
| noexcept

Default constructor.

## ◆ ~DefaultRenderStrategy()

virtual nkGraphics::DefaultRenderStrategy::~DefaultRenderStrategy | ( |  | ) |
| virtual

Destructor.

## Member Function Documentation

## ◆ getSlots()

const nkMemory::BufferCast<SlotEntry>& nkGraphics::DefaultRenderStrategy::getSlots | ( |  | ) | const

Returns
  The slots currently tracked by the strategy, based on the update events provided.

## ◆ getLodQualityFactor()

float nkGraphics::DefaultRenderStrategy::getLodQualityFactor | ( |  | ) | const

Returns
  Currently used quality factor for the LOD selection.

## ◆ getFrustumCull()

bool nkGraphics::DefaultRenderStrategy::getFrustumCull | ( |  | ) | const

Returns
  Whether the strategy will frustum cull (true) or not (false), when generating the command queue.

## ◆ getOrderQueue()

bool nkGraphics::DefaultRenderStrategy::getOrderQueue | ( |  | ) | const

Returns
  Whether the strategy will reorder the commands (true) or not (false), wheen generating the command queue.

## ◆ getUseLodSystem()

bool nkGraphics::DefaultRenderStrategy::getUseLodSystem | ( |  | ) | const

Returns
  Whether the strategy is running its LOD selection logic (true) or not (false).

## ◆ setLodQualityFactor()

void nkGraphics::DefaultRenderStrategy::setLodQualityFactor | ( | float | value | ) |

Sets the quality factor used for LOD selection. This is a direct multiplier for an object's height ratio when comparing it against the view's height. As an example, if an object has a height accounting for 20% of the view and the quality factor is set to 2, then the retained ratio will be 40%. By default, this is set to 1.

Parameters

  value | The factor to use during LOD selection.

## ◆ setFrustumCull()

void nkGraphics::DefaultRenderStrategy::setFrustumCull | ( | bool | value | ) |

Sets whether the strategy should frustum cull or not when generating the command queue. Frustum culling adds a check when baking the LODs to render, by checking their bounds against the active camera frustum. If they are not inside, implying they won't color any pixels, then the drawing command won't be issued in the first place. On by default, this can be turned off to reduce load on CPU if required.

Parameters

  value | Whether the culling should happen (true) or not (false).

## ◆ setOrderQueue()

void nkGraphics::DefaultRenderStrategy::setOrderQueue | ( | bool | value | ) |

Sets whether the strategy should reorder its commands or not within the command queue. Reordering aims to reduce the number of potential state switching required by the renderer, and improve drawing speed / quality. It will :

    - If transparent :
        - Reorder from back to front to properly handle alpha blending
    - If not transparent :
        - If MonoMaterialPass :
            - Order by Mesh ID first to reduce the number of vertex buffer changes
            - Order from front to back to try to limit overdraw
        - If RenderScenePass :
            - Order by Program ID to reduce the number of PSO switches
            - Order by Mesh ID to then reduce the number of vertex buffer changes
            - Order from front to back to try to limit overdraw

Enabling it also allows to further optimize the queue as it will improve the command collapsing results, as similar resources using commands they get packed together. On by default, this can be turned off to reduce load on CPU if required.

Parameters

  value | Whether the reordering should happen (true) or not (false).

## ◆ setUseLodSystem()

void nkGraphics::DefaultRenderStrategy::setUseLodSystem | ( | bool | value | ) |

Sets whether the strategy should run its LOD selection logic during rendering.
If enabled, LOD selection will happen based an object's height ratio, compared against the view's height at object's distance. The metric is then expected to be a float within [0, 1+]. For instance, if a LOD level is marked with 0.6 as a value, then this LOD level will be used with the item is taking up to 60% of the view.
On by default, this can be turned off to reduce load on CPU if required. The LOD at index 0 will then be selected.

Parameters

  value | Whether the LOD selection should happen (true) or not (false).

## ◆ bakeRenderCommandQueue()

virtual RenderCommandQueue nkGraphics::DefaultRenderStrategy::bakeRenderCommandQueue | ( | Shader * | shader,
|  | bool | transparent
| ) |  |
| override virtual

Generates the final command queue that will be communicated to the active Renderer. This method is called whenever a RenderQueue is rendered, and should return the queue to be executed from it.

Parameters

  shader | A shader, provided by a MonoMaterialPass if it is the caller, nullptr otherwise.
  transparent | Whether the pass has been marked as transparent (true) or not (false).

Returns
  The final baked command queue, created from all the information and states provided.

Implements nkGraphics::RenderStrategy.

## ◆ updateAddRenderSlot()

virtual void nkGraphics::DefaultRenderStrategy::updateAddRenderSlot | ( | Entity * | ent,
|  | const EntityRenderInfoSlot * | slot
| ) |  |
| override virtual

Called whenever a parent RenderQueue's Entity gets a new slot added to it.

Parameters

  ent | The entity calling.
  slot | The slot newly created.

Remarks
  This method can be used to follow in parallel what a RenderQueue is doing, and track data in a more fitting format.

Implements nkGraphics::RenderStrategy.

## ◆ updateEraseRenderSlot()

virtual void nkGraphics::DefaultRenderStrategy::updateEraseRenderSlot | ( | Entity * | ent,
|  | const EntityRenderInfoSlot * | slot
| ) |  |
| override virtual

Called whenever a parent RenderQueue's Entity loses a slot.

Parameters

  ent | The entity calling.
  slot | The slot erased.

Remarks
  This method can be used to follow in parallel what a RenderQueue is doing, and keep data in a more fitting format.

Implements nkGraphics::RenderStrategy.

The documentation for this class was generated from the following file:

- Documentation/Headers/NilkinsGraphics/RenderQueues/RenderStrategies/DefaultRenderStrategy.h